package xzl.edu.cn.set.name;

//import java.lang.Comparable;

public class Student extends Person implements Comparable {
	public Student(String firstname, char mi, String lastname, String name, String major) {
		super(firstname, mi, lastname, name);
		this.major = major;
	}

	public String major;

	public String getMajor() {
		return major;

	}

	public String toString() {
		return super.toString() + "Major:" + major;

	}

	/**
	 * 排序方式：Major->lastname->firstname->mi
	 */

	public int compareTo(Object obj) {
		Student other = (Student) obj;
		if (major.compareTo(other.getMajor()) > 0)
			return 1;
		if (major.compareTo(other.getMajor()) < 0)
			return -1;
		if (lastname.compareTo(other.getLastname()) > 0)
			return 1;
		if (lastname.compareTo(other.getLastname()) < 0)
			return -1;
		if (firstname.compareTo(other.getFirstname()) > 0)
			return 1;
		if (firstname.compareTo(other.getFirstname()) < 0)
			return -1;
		if (mi > other.getMi())
			return 1;
		if (mi < getMi())
			return -1;
		return 0;
	}
}
